<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * 
 * Performance Controller
 * @author Denis, Simon, Dennis
 *
 */
class Performance extends CI_Controller {
	
	public function __construct()
	{
	parent::__construct();
	require_once('user.php');
	$this->user=new User();

	}
	
	/**
	* Index Page for this controller.
	*
	*/
	public function index()
	{
		$this->load->view('header');
		$loggedIn = $this->user->logged_in();
		$loginData['isLoggedIn'] = $loggedIn;
		if($loggedIn){
			$loginData['username'] = $_SESSION['username'];
		}
		$this->load->view('login', $loginData);

		$menu['activeController'] = 'performance';
		$this->load->view('menu',$menu);
		if($loggedIn==true) {
			$this->load->view('performance');
		} else {
			$this->load->view('503');
		}
		$this->load->view('footer');
	}
	/**
	* method to show statistics from the user
	* !unfinished!
	*/
	public function statistics()
	{
		$this->load->view('header');
		$loggedIn = $this->user->logged_in();
		$loginData['isLoggedIn'] = $loggedIn;
		if($loggedIn){
			$loginData['username'] = $_SESSION['username'];
		}
		$this->load->view('login', $loginData);
	
		$menu['activeController'] = 'performance';
		$this->load->view('menu',$menu);
		$this->load->view('performance_statistics');
		$this->load->view('footer');
	}
	
	/**
	 * method to show the top10 users. sorted by the scalepoints of a user
	 */
	public function top10()
	{
		$this->load->view('header');
		$loggedIn = $this->user->logged_in();
		$loginData['isLoggedIn'] = $loggedIn;
		if($loggedIn){
			$loginData['username'] = $_SESSION['username'];
		}
		$this->load->view('login', $loginData);


		$data['query']=$this->user_model->getTopUsers();
		
		$menu['activeController'] = 'performance';
		$this->load->view('menu',$menu);
		$this->load->view('performance_top10',$data);
		$this->load->view('footer');
	}
}